from tkinter import *

root=Tk()


sb=Scrollbar(root)
sb.pack(side=RIGHT,fill=Y)


lb=Listbox(root,yscrollcommand = sb.set) #水平滚动条把yscrollcommand改为xscrollcommand


for i in range(1000):
    lb.insert(END,i)

lb.pack(side=LEFT,fill=Y)

sb.config(command=lb.yview)#水平滚动条把yview改为xview


mainloop()
